package com.yangming.springboot.controller;


import com.yangming.springboot.model.TreeDto;
import com.yangming.springboot.service.ModuleService;
import io.swagger.models.Model;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RequestMapping(value = "module")
@Controller
public class ModuleController extends BaseController {

    @Resource
    private ModuleService moduleService;

    @RequestMapping(value = "list")
    @ResponseBody
    public List<TreeDto> queryAllModules(Integer roleId){

        return moduleService.queryAllModules(roleId);
    }

    /**
     * 视图转发*/
    @RequestMapping(value = "")
    public String toAddGrantPage(Integer id, Model model){
//        model.addAttribute("roleId", id);
        return "role/gtant";
    }

    @RequestMapping(value = "addGrant")
    public void addGrant(){

    }









    @RequestMapping(value = "modulelist")
    @ResponseBody
    public Map<String, Object> queryModules(){
        return moduleService.queryModules();
    }

    //视图转发路径
    @RequestMapping(value = "index")
    public String index(){
        return "modules/index";
    }
}
